// Data.java

package com.ruoyi.service.entity.order.pay;

import com.ruoyi.service.domain.ServiceOrders;
import com.ruoyi.service.domain.ServiceUsers;
import com.ruoyi.service.entity.order.*;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List;

@lombok.Data
public class PCOrderPayRet {
    private Long orderId;
    private String orderIdVO;
    private String orderPayId;

    private String orderCode;
    private String orderStatus;

    private String orderCreateTime;
    private String orderPayTime;
    private String orderSettleTime;

    private PCAppointmentInfo userInfo;

    private PCServeInfo serveInfo;

    private String itemDesc;

    private List<PCNurseInfo> nurseInfo;


    private Long totalService;
    private Long totalPackage;
    private Long totalTaxi;
    private Long totalOther;
    private Long total;
    private PCOrderDetailInfo orderInfo;

    private List<PCOrderButton> buttons;
    //private List<PCProcessItems> items;

    //private List<PCOrderProcess> process;


    public void init(ServiceOrders order) {
        this.orderId = order.getOrderId();
        this.orderIdVO = order.getOrderCode();
        DateFormat cstFormate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String creatTimeNew = cstFormate.format(order.getOrderCreateTime());
        this.orderCreateTime = creatTimeNew;

        switch (order.getOrderServiceflag()){
            case 11:
                this.setOrderCode("unSubmit");
                this.setOrderStatus("未提交结算");
                break;
            case 12:
            case 13:
            case 14:
                this.setOrderCode("submit");
                this.setOrderStatus("未核查已提交");
                break;
            case 15:
                this.setOrderCode("check");
                this.setOrderStatus("已核查");
                break;
            //case 14:
            //case 15:
            //case 16:
            //case 17:
            //    this.setOrderCode("settled");
            //    this.setOrderStatus("已结算");
            //    break;
            default:
                this.setOrderCode("normal");
                this.setOrderStatus("正常");
        }

        //if (order.getOrderStatus() != 0){
        //    switch (order.getOrderStatus()){
        //        case 1:
        //            this.setOrderCode("otSend");
        //            this.setOrderStatus("超时预警(派单)");
        //            break;
        //        case 2:
        //            this.setOrderCode("otAccept");
        //            this.setOrderStatus("超时预警(接单)");
        //            break;
        //        case 3:
        //            this.setOrderCode("otStart");
        //            this.setOrderStatus("超时未开始");
        //            break;
        //        case 4:
        //            this.setOrderCode("otEnd");
        //            this.setOrderStatus("超时未结束服务");
        //            break;
        //        case 5:
        //            this.setOrderCode("otCheck");
        //            this.setOrderStatus("超时未提交结算");
        //            break;
        //        case 6:
        //            this.setOrderCode("otEndPay");
        //            this.setOrderStatus("超时未结算尾款");
        //            break;
        //    }
        //}else{
        //    this.setOrderCode("normal");
        //    this.setOrderStatus("正常");
        //}

        if(this.userInfo == null){
            this.userInfo = new PCAppointmentInfo();
        }
        this.userInfo.setAppointmentDesc(order.getOrderRemark());
    }


    public void initUserInfo(ServiceUsers userInfo) {
        if(this.userInfo == null){
            this.userInfo = new PCAppointmentInfo();
        }
        this.userInfo.setAppointmentId(userInfo.getUsersId());
        this.userInfo.setAppointmentName(userInfo.getUsersName());
        this.userInfo.setAppointmentTel(userInfo.getUsersTelephone());
    }

    //public void initOrderItem(List<PCProcessItems> items) {
    //    this.items = items;
    //}

    //public void initProcess(List<PCOrderProcess> process) {
    //    this.process = process;
    //}

    public void initOrderInfo(PCPaidInfo paidInfo) {

        PCOrderDetailInfo info = new PCOrderDetailInfo();
        info.init(paidInfo.getActual(), paidInfo.getPrePaid(), paidInfo.getDifference());
        this.orderInfo = info;
        List<PCServiceItemsItem> items = info.getServiceItems().getItems();
        List<PCPackageItemsItem> packages = info.getPackageItems().getItems();
        List<PCTaxiItemsItem> taxis = info.getTaxiItems().getItems();
        List<PCOtherItemsItem> others = info.getOtherItems().getItems();

        this.totalService = 0L;
        for (PCServiceItemsItem item : items){
            this.totalService = this.totalService + item.getAmount();
        }
        this.totalPackage = 0L;
        for (PCPackageItemsItem item : packages){
            this.totalPackage = this.totalPackage + item.getAmount();
        }
        this.totalTaxi = 0L;
        for (PCTaxiItemsItem item : taxis){
            this.totalTaxi = this.totalTaxi + item.getAmount();
        }
        this.totalOther = 0L;
        for (PCOtherItemsItem item : others){
            this.totalOther = this.totalOther + item.getAmount();
        }
        this.total = this.totalService + this.totalPackage + this.totalTaxi + this.totalOther;

    }
}